package com.fancon.android.emoji.widget;



import android.content.Context;
import android.text.Editable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.fancon.android.emoji.R;

public class EmojiEditText extends LinearLayout{
	//private Context mContext;
	private View mBaseView;
	private ImageView emojiBtn;
	//private EmojiUtil mEmojiUtil;
	private RichEditText emojiTxt;
	public EmojiEditText(Context context, AttributeSet attrs) {
		super(context);
		// TODO Auto-generated constructor stub
		//this.mContext = context;
		LayoutInflater layoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mBaseView = layoutInflater.inflate(R.layout.rich_edit_text,
				this);
		emojiBtn = (ImageView) findViewById(R.id.emoji_btn);
		emojiTxt = new RichEditText(context, attrs);
		// insert into main view
		LinearLayout richWrapper = (LinearLayout) findViewById(R.id.rich_wrapper);
		richWrapper.addView(emojiTxt, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
		//mEmojiUtil = ((IRichGlobalState) (((Activity)mContext).getApplication())).getEmojiUtil();
		emojiTxt.bindKeyBoard(emojiBtn, false);
	}
	public void hideKeyBoard(){
		//InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Activity.INPUT_METHOD_SERVICE);
			//imm.hideSoftInputFromWindow(emojiTxt.getWindowToken(), 0);
		emojiTxt.hideKeyBoard();
	}
	public EmojiEditText(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}
	public View getmBaseView() {
		return mBaseView;
	}
	public void setmBaseView(View mBaseView) {
		this.mBaseView = mBaseView;
	}
	public ImageView getEmojiBtn() {
		return emojiBtn;
	}
	public void setEmojiBtn(ImageView emojiBtn) {
		this.emojiBtn = emojiBtn;
	}
	public EditText getEmojiTxt() {
		return emojiTxt;
	}
	public void setEmojiTxt(RichEditText emojiTxt) {
		this.emojiTxt = emojiTxt;
	}
	
	public void setText(String utf8String){
		emojiTxt.setText(utf8String);
	}
	public Editable getText(){
		return emojiTxt.getText();
	}
	public String getRichText(){
		return emojiTxt.getRichText();
	}
}

